# CC = cc
# CF = -O

default: all

include ../../SuiteSparse_config/SuiteSparse_config.mk

I = -I../../SuiteSparse_config -I../Include

all: libcxsparse.a

CS_SOURCE = cs_add.c cs_amd.c cs_chol.c cs_cholsol.c cs_counts.c cs_cumsum.c \
	cs_droptol.c cs_dropzeros.c cs_dupl.c cs_entry.c \
	cs_etree.c cs_fkeep.c cs_gaxpy.c cs_happly.c cs_house.c cs_ipvec.c \
	cs_lsolve.c cs_ltsolve.c cs_lu.c cs_lusol.c cs_util.c cs_multiply.c \
	cs_permute.c cs_pinv.c cs_post.c cs_pvec.c cs_qr.c cs_qrsol.c \
	cs_scatter.c cs_schol.c cs_sqr.c cs_symperm.c cs_tdfs.c cs_malloc.c \
	cs_transpose.c cs_compress.c cs_usolve.c cs_utsolve.c cs_scc.c \
	cs_maxtrans.c cs_dmperm.c cs_updown.c cs_print.c cs_norm.c cs_load.c \
	cs_dfs.c cs_reach.c cs_spsolve.c cs_leaf.c cs_ereach.c cs_randperm.c

CS_DI_OBJ =  cs_add_di.o cs_amd_di.o cs_chol_di.o cs_cholsol_di.o cs_counts_di.o \
	cs_cumsum_di.o cs_droptol_di.o cs_dropzeros_di.o cs_dupl_di.o \
	cs_entry_di.o cs_etree_di.o cs_fkeep_di.o cs_gaxpy_di.o cs_happly_di.o \
	cs_house_di.o cs_ipvec_di.o cs_lsolve_di.o cs_ltsolve_di.o cs_lu_di.o \
	cs_lusol_di.o cs_util_di.o cs_multiply_di.o cs_permute_di.o cs_pinv_di.o \
	cs_post_di.o cs_pvec_di.o cs_qr_di.o cs_qrsol_di.o cs_scatter_di.o \
	cs_schol_di.o cs_sqr_di.o cs_symperm_di.o cs_tdfs_di.o cs_malloc_di.o \
	cs_transpose_di.o cs_compress_di.o cs_usolve_di.o cs_utsolve_di.o \
	cs_scc_di.o cs_maxtrans_di.o cs_dmperm_di.o cs_updown_di.o cs_print_di.o \
	cs_norm_di.o cs_load_di.o cs_dfs_di.o cs_reach_di.o cs_spsolve_di.o \
	cs_leaf_di.o cs_ereach_di.o cs_randperm_di.o

CS_DL_OBJ =  cs_add_dl.o cs_amd_dl.o cs_chol_dl.o cs_cholsol_dl.o cs_counts_dl.o \
	cs_cumsum_dl.o cs_droptol_dl.o cs_dropzeros_dl.o cs_dupl_dl.o \
	cs_entry_dl.o cs_etree_dl.o cs_fkeep_dl.o cs_gaxpy_dl.o cs_happly_dl.o \
	cs_house_dl.o cs_ipvec_dl.o cs_lsolve_dl.o cs_ltsolve_dl.o cs_lu_dl.o \
	cs_lusol_dl.o cs_util_dl.o cs_multiply_dl.o cs_permute_dl.o cs_pinv_dl.o \
	cs_post_dl.o cs_pvec_dl.o cs_qr_dl.o cs_qrsol_dl.o cs_scatter_dl.o \
	cs_schol_dl.o cs_sqr_dl.o cs_symperm_dl.o cs_tdfs_dl.o cs_malloc_dl.o \
	cs_transpose_dl.o cs_compress_dl.o cs_usolve_dl.o cs_utsolve_dl.o \
	cs_scc_dl.o cs_maxtrans_dl.o cs_dmperm_dl.o cs_updown_dl.o cs_print_dl.o \
	cs_norm_dl.o cs_load_dl.o cs_dfs_dl.o cs_reach_dl.o cs_spsolve_dl.o \
	cs_leaf_dl.o cs_ereach_dl.o cs_randperm_dl.o

CS_CI_OBJ =  cs_add_ci.o cs_amd_ci.o cs_chol_ci.o cs_cholsol_ci.o cs_counts_ci.o \
	cs_cumsum_ci.o cs_droptol_ci.o cs_dropzeros_ci.o cs_dupl_ci.o \
	cs_entry_ci.o cs_etree_ci.o cs_fkeep_ci.o cs_gaxpy_ci.o cs_happly_ci.o \
	cs_house_ci.o cs_ipvec_ci.o cs_lsolve_ci.o cs_ltsolve_ci.o cs_lu_ci.o \
	cs_lusol_ci.o cs_util_ci.o cs_multiply_ci.o cs_permute_ci.o cs_pinv_ci.o \
	cs_post_ci.o cs_pvec_ci.o cs_qr_ci.o cs_qrsol_ci.o cs_scatter_ci.o \
	cs_schol_ci.o cs_sqr_ci.o cs_symperm_ci.o cs_tdfs_ci.o cs_malloc_ci.o \
	cs_transpose_ci.o cs_compress_ci.o cs_usolve_ci.o cs_utsolve_ci.o \
	cs_scc_ci.o cs_maxtrans_ci.o cs_dmperm_ci.o cs_updown_ci.o cs_print_ci.o \
	cs_norm_ci.o cs_load_ci.o cs_dfs_ci.o cs_reach_ci.o cs_spsolve_ci.o \
	cs_leaf_ci.o cs_ereach_ci.o cs_randperm_ci.o

CS_CL_OBJ =  cs_add_cl.o cs_amd_cl.o cs_chol_cl.o cs_cholsol_cl.o cs_counts_cl.o \
	cs_cumsum_cl.o cs_droptol_cl.o cs_dropzeros_cl.o cs_dupl_cl.o \
	cs_entry_cl.o cs_etree_cl.o cs_fkeep_cl.o cs_gaxpy_cl.o cs_happly_cl.o \
	cs_house_cl.o cs_ipvec_cl.o cs_lsolve_cl.o cs_ltsolve_cl.o cs_lu_cl.o \
	cs_lusol_cl.o cs_util_cl.o cs_multiply_cl.o cs_permute_cl.o cs_pinv_cl.o \
	cs_post_cl.o cs_pvec_cl.o cs_qr_cl.o cs_qrsol_cl.o cs_scatter_cl.o \
	cs_schol_cl.o cs_sqr_cl.o cs_symperm_cl.o cs_tdfs_cl.o cs_malloc_cl.o \
	cs_transpose_cl.o cs_compress_cl.o cs_usolve_cl.o cs_utsolve_cl.o \
	cs_scc_cl.o cs_maxtrans_cl.o cs_dmperm_cl.o cs_updown_cl.o cs_print_cl.o \
	cs_norm_cl.o cs_load_cl.o cs_dfs_cl.o cs_reach_cl.o cs_spsolve_cl.o \
	cs_leaf_cl.o cs_ereach_cl.o cs_randperm_cl.o

CS = cs_convert.o $(CS_DI_OBJ) $(CS_DL_OBJ) $(CS_CI_OBJ) $(CS_CL_OBJ)

$(CS): ../Include/cs.h Makefile

cs_convert.o: ../Source/cs_convert.c
	$(CC) $(CF) $(I) -c $< -o $@

%_di.o : ../Source/%.c
	$(CC) $(CF) $(I) -c $< -o $@

%_dl.o : ../Source/%.c
	$(CC) $(CF) $(I) -DCS_LONG -c $< -o $@

%_ci.o : ../Source/%.c
	$(CC) $(CF) $(I) -DCS_COMPLEX -c $< -o $@

%_cl.o : ../Source/%.c
	$(CC) $(CF) $(I) -DCS_LONG -DCS_COMPLEX -c $< -o $@

libcxsparse.a: $(CS)
	$(ARCHIVE)  libcxsparse.a $(CS)
	- $(RANLIB) libcxsparse.a

clean:
	- $(RM) *.o

purge: distclean

distclean: clean
	- $(RM) *.a
